package com.zt.rongda.dashboard.service;

import com.zt.constant.Constants;
import com.zt.rongda.constant.BusConstant;
import com.zt.rongda.employee.inter.EmployeeMapper;
import com.zt.rongda.employee.model.Employee;
import com.zt.servlet.ReqBean;
import com.zt.system.model.BusinessException;
import com.zt.system.model.Department;
import com.zt.system.model.SqlBuilder;
import com.zt.system.model.User;
import com.zt.system.service.BaseService;
import com.zt.system.service.IDepartmentService;
import com.zt.system.service.IEmployeeService;
import com.zt.system.service.IUserService;
import com.zt.util.StringUtil;
import java.util.*;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class DashboardService extends BaseService {

    public JSONArray mtApplyQuery(ReqBean reqBean) {
        String sql = "SELECT m.*,(SELECT e.EMP_NAME FROM EMPLOYEE e where e.EMP_ID = m.REPAIR_EMP_ID) repairEmpName, "
                + "b.BUS_TYPE,b.STOP_PLACE,t.WORK_GROUP_ID,g.GROUP_NAME FROM MAINTENANCE_APPLY m "
                + "LEFT JOIN MEDIA_BUS b ON b.BUS_ID = m.MEDIA_ID "
                + "LEFT JOIN MAINTENANCE_TASK t ON t.MAINTENANCE_ID = m.MAINTENANCE_ID AND t.C_TASK_TYPE = ? "
                + "LEFT JOIN EMPLOYEE_GROUP g ON g.GROUP_ID = t.WORK_GROUP_ID where m.`STATUS` <> ?";
        return query(sql, BusConstant.TaskType.TASK_TYPE_REPAIR, BusConstant.MaintenanceApply.APPLY_STATUS_COMPLETE);
    }
}
